package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IEditEngineeringInstallOrderView;
import com.cloudsigns.factorymanager2.engineering.model.EditEngineeringInstallOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.IEditEngineeringInstallOrderModel;

/**
 * Created by tony on 2018/4/6.
 */

public class EditEngineeringInstallOrderPresenter {
    private IEditEngineeringInstallOrderView view;
    private IEditEngineeringInstallOrderModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EditEngineeringInstallOrderPresenter(IEditEngineeringInstallOrderView view) {
        this.view = view;
        this.model = new EditEngineeringInstallOrderModel();
    }

    public void editEngineeringInstallOrder() {


        model.editEgnineeringInstallOrder(view.getBeginDate(), view.getFinishDate(), view.getId(), new EditEngineeringInstallOrderModel.OnEditEngineeringInstallOrderListener() {
            @Override
            public void editEngineeringInstallOderSunccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.editEngineeringInstallOderSunccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void editEngineeringInstallOderFailed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.editEngineeringInstallOderFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });

    }
}
